Skip to content

Add Webm medium quality preset and fix MP4/Webm presets - #385

Merged
benoit74 merged 2 commits into
openzim:mainfrom
pawank925:issue-271-webm-medium-mp4-high
Nov 12, 2026
Merged

benoit74 merged 2 commits into
openzim:mainfrom
pawank925:issue-271-webm-medium-mp4-high

Conversation

@pawank925

Copy link
Copy Markdown
Contributor

Fixes #271.

Changes

  • Added VideoWebmMedium (VP9, v1): 240k target bitrate, -qmin 32 -qmax 58, -speed 3, height capped at 720 (scale='-2:min(720,ih)':force_original_aspect_ratio=increase), Vorbis 48k/44.1kHz stereo — a middle ground between VideoWebmLow and VideoWebmHigh.
  • Fixed VideoMp4High (v2): changed CRF from 20 to 28 (CRF 20 often produced files larger than the input) and added -movflags +faststart for progressive playback.
  • All Webm presets (VideoWebmLow, VideoWebmMedium, VideoWebmHigh) now pass -row-mt 1 for faster VP9 encoding (as recommended in Add Webm medium quality + fix MP4 high quality presets #271).
  • Bumped VideoWebmLow to v4 and VideoWebmHigh to v3 to reflect the -row-mt option change.
  • Updated preset unit tests and CHANGELOG.md.

Notes

@pawank925
pawank925 force-pushed the issue-271-webm-medium-mp4-high branch 3 times, most recently from d3e4af2 to 5567ebd Compare November 6, 2026 16:30
@codecov

codecov Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (dbb7534) to head (9c7c2c4).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #385   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           42        42           
  Lines         2947      2952    +5     
  Branches       452       452           
=========================================
+ Hits          2947      2952    +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pawank925

Copy link
Copy Markdown
Contributor Author

@benoit74

@benoit74

benoit74 commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

@pawank925 did you tested that against some real videos? We used to have some test videos but I don't find them anymore ...

@pawank925

pawank925 commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor Author

@benoit74 Yes — and the videos are still in the repo, I think you're remembering the other set.

tests/files/video.mp4, video.mkv and video.webm (plus audio.mp3) are the fixture videos, added back in a5ae0421 (2020-05-20) and unchanged since. They're real footage, not generated patterns: 1920x800, 24 fps, 2.63 s / 63 frames. The set that is genuinely lost is the three videos from #79 (Khan Academy chalkboard, TED talk, news spot) that you mentioned in #271.

The two new @pytest.mark.slow cases in this PR do run on those fixtures (video.mp4 -> VideoWebmMedium, video.mkv -> VideoMp4High), and CI executes them via --runslow — all green on db8e16e. But those assertions only check codec and duration, which says nothing about whether the preset is actually sane. So I also ran the presets locally (static ffmpeg 9.0, arm64, VMAF against the fixture itself as reference; input = 1,259,106 B) and measured the output:

preset output vs input VMAF mean
VideoWebmLow v4 94,186 B 7.5% 31.7
VideoWebmMedium v1 125,139 B 9.9% 46.2
VideoWebmHigh v3 178,786 B 14.2% 56.7
VideoMp4High CRF 28 (new) 732,813 B 58% 91.1
VideoMp4High CRF 20 (old) 1,408,804 B 112% 97.8

Three things worth noting from that:

  • Medium lands between low and high on both size and VMAF, which is the intent.
  • The CRF 20 -> 28 change is the fix the PR body claims: CRF 20 produced a file larger than its input on this clip, CRF 28 gives 58% of the input at VMAF 91.
  • -row-mt 1 is a speed option, not a quality one: WebmLow goes 94,315 B -> 94,186 B with it, i.e. the same output within 0.1%. Matches @DasDunkel's "same size and quality file" in Add Webm medium quality + fix MP4 high quality presets #271. I still bumped the preset VERSION because the output bytes do change and scrapers key their caches on it — but happy to drop that if you'd rather not invalidate caches for a 0.1% difference.

The honest limitation: this is one 2.6-second clip of one kind of content, so it is nowhere near the "significantly tested on multiple kinds of videos" bar you set in #271. The parameters themselves come from @DasDunkel's 15-video YouTube set and the comparison script in #271, not from my own testing — my runs only confirm they behave as described, they don't re-validate them across content types.

If you want that before merge, I can re-run @DasDunkel's script over the 15 IDs (low/med/high, webm + mp4) and report the full per-video numbers. And if you'd like the repo to stop losing its test set, adding a couple of varied fixtures to tests/files/ — static-background lecture slides and something with fast motion — would let the slow tests assert size/quality rather than just codecs.

@benoit74 benoit74 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I feel like this is good to merge. Especially since we can anyway later improve on that basis.

Interested to have @rgaudin view on that (if any).

@benoit74
benoit74 force-pushed the issue-271-webm-medium-mp4-high branch from db8e16e to 9c7c2c4 Compare November 12, 2026 21:04
@benoit74
benoit74 merged commit 657fe48 into openzim:main Nov 12, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Webm medium quality + fix MP4 high quality presets

2 participants